import java.io.UnsupportedEncodingException;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import cn.smartv.livemanager.basedata.domain.CommonImage;
import cn.smartv.system.response.MsgObj;



/** 上传图片  处理方法
	 * @param file
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	@RequestMapping(value = "/image/upload", method = { RequestMethod.POST,
			RequestMethod.GET }, produces = "text/html;charset=UTF-8")
	public @ResponseBody
	String uploadProgramImage(
			@RequestParam(value = "file", required = false) MultipartFile file)
			throws UnsupportedEncodingException {
		CommonImage ci = imageService.uploadImage(file);
		MsgObj  msg=MsgObj.newInstance();
		if(ci.getStorageUrl()!=null&&ci.getStorageUrl().length()>0)
		    msg.setSuccess("true");
		else
			msg.setSuccess("false");	
		msg.setData(ci);
		msg.setMessage(ci.getMsg());
		return msg.toJsonStr();
	}
